package cn.zynworld.saas.user.service.converter;

import cn.zynworld.saas.user.api.dto.UserDTO;
import cn.zynworld.saas.user.biz.domain.User;

/**
 * Created by zhaoyuening on 2018/1/20.
 */
public class UserConverter {
    public static UserDTO user2userDTO(User user){
        if (user == null){
            return null;
        }
        UserDTO userDTO = new UserDTO();
        userDTO.setAge(user.getAge())
                .setId(user.getId())
                .setName(user.getName())
                .setPassword(user.getPassword());
        return userDTO;
    }


    public static User userDTO2user(UserDTO userDTO){
        if (userDTO == null){
            return null;
        }
        User user = new User();
        user.setAge(userDTO.getAge());
        user.setId(userDTO.getId());
        user.setName(userDTO.getName());
        user.setPassword(userDTO.getPassword());
        return user;
    }


}
